﻿@model PhoneBilling.Models.TraiffModel
@{
    ViewBag.Title = "费率管理";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
<div class="traiff">
<script type="text/javascript">
    function changeTraiff() {
        window.location.href = "/Manage/Traiff/" + $("#traffList").val();
    }

    function modifyTraiffDetail(id) {
        
        window.location.href = "/Manage/TraiffDetail?tariffID=" + $("#traffList").val() + "&areaCode=" + id;
    }

    function deleteTraiffDetail(id) {
        var msg = "确定删除费率(区号"+id+")？";
        var result = confirm(msg);
        if (result==true)
            window.location.href = "/Manage/DeleteTraiffDetail?tariffID=" + $("#traffList").val() + "&areaCode=" + id;
    }
    function se() {
        window.location.href = "/Manage/Traiff?id=" + $("#traffList").val() + "&area=" + $(".se").val();
    }
    function del(id, name) {
        var r = confirm("确认删除区号：" + name + "吗？");
        if (r == true) {
            window.location.href = "/Manage/DeleteTraiffDetail?tariffID=" + id + "&areaCode="+name;
        }
        return false;
    }
</script>
<script type="text/javascript">
    $(document).ready(function () {
        $("#btnNewTraiffDetail").ligerButton(
        {
            width:120,
            click: function () {
                window.location.href = "/Manage/TraiffDetail?tariffID=@Model.CurrentTraiff";
            }
        });
        $("#btnSearch").ligerButton(
        {
            click: function () {
                se();
            }
        })
    });
</script>
@if (Model.Message != null){<h2>@Model.Message</h2>}
<div class="system_input_contain">
    <label for>当前费率表：</label>
    @Html.DropDownListFor(m => m.CurrentTraiff, new SelectList(Model.TraiffList, "ID", "Name"), new { id = "traffList", style = "input-text", onchange = "changeTraiff()" }) 
    <input type="button" id="btnNewTraiffDetail" value="新增费率明细" />
</div>
@using (Html.BeginForm())
{
    <div class="system_input_contain">
     @Html.HiddenFor(m => m.CurrentTraiff)
     @Html.LabelFor(m => m.区号)
     @Html.TextBoxFor(m => m.区号, new { @class ="se" })
     <input type="button" id="btnSearch" value="搜索" />
     </div>
}
<div class="system_toolbar">
    <input type="button" id="btnNew" value="新增" />
    <input type="button" id="btnModify" value="修改" />
    <input type="button" id="btnDelete" value="删除" />
</div>
<div id="maingrid"></div>
@{
    System.Text.StringBuilder sb = new System.Text.StringBuilder();
    sb.AppendLine(string.Format("var data={{Total:{0},", Model.TraiffDetailList.Count));
    sb.AppendLine("Rows:[");
    for (int i = 0; i < Model.TraiffDetailList.Count; i++)
    {
        var item = Model.TraiffDetailList[i];
        if(i == 0)
        {
            sb.Append("{");
        }
        else
        {
            sb.Append(",{");
        }
        sb.Append(string.Format("区号:'{0}',", item.区号));
        sb.Append(string.Format("地名:'{0}',", item.地名));
        sb.Append(string.Format("话类:'{0}',", item.话类));
        sb.Append(string.Format("基本费:'{0}',", item.基本费));
        sb.Append(string.Format("附加费:'{0}',", item.附加费));
        sb.Append(string.Format("服务费:'{0}',", item.服务费));
        sb.Append(string.Format("基本费计次秒:'{0}',", item.基本费计次秒));
        sb.Append(string.Format("服务费计次秒:'{0}',", item.服务费计次秒));
        sb.Append(string.Format("分段计费方法:'{0}'", item.分段计费方法));
        sb.Append("}");
    }
    sb.AppendLine("]};");
    string data = sb.ToString();
}
<script type="text/javascript">
    @Html.Raw(data)
    
    var menu = $.ligerMenu({ top: 100, left: 100, width: 120, items:
            [
            { text: '新增', click: newclick },
            { line: true },
            { text: '修改', click: modifyclick },
            { line: true },
            { text: '删除', click: deleteclick }
            ]
        });
    var grid;
    $(function () {

        grid = $("#maingrid").ligerGrid({
            columns: [
                { display: '区号', name: '区号',width:100},
                { display: '地名', name: '地名',width:100},
                { display: '话类', name: '话类',width:140},
                { display: '基本费', name: '基本费',width:80},
                { display: '附加费', name: '附加费',width:80},
                { display: '服务费', name: '服务费',width:80},
                { display: '基本费计次秒', name: '基本费计次秒',width:80},
                { display: '服务费计次秒', name: '服务费计次秒',width:80},
                { display: '分段计费方法', name: '分段计费方法',width:160}
                ],
                isScroll: false, data: data,pageSize:30,alternatingRow:true,  
                onContextmenu: function (node, e) {
            actionNodeID = node;
            menu.show({ top: e.pageY, left: e.pageX });
            return false;
        }
        }
        );resetGridHeight(grid);
        $(window).resize(function () {
                resetGridHeight(grid);
            });
    });    function newclick(item, i) {
        var path = "/Manage/TraiffDetail?tariffID=@Model.CurrentTraiff";
        window.location.href=path;
    }
    function modifyclick(item, i) {
        var path = "/Manage/TraiffDetail?tariffID=@Model.CurrentTraiff&areaCode="+actionNodeID.data.区号;
        window.location.href=path;
    }    function deleteclick(item, i) {
        del('@Model.CurrentTraiff',actionNodeID.data.区号);
    }
    $(document).ready(function () {
        $("#btnNew").ligerButton(
        {
            click: function () {
                window.location.href = "/Manage/TraiffDetail?tariffID=@Model.CurrentTraiff";
            }
        });
        $("#btnModify").ligerButton(
        {
            click: function () {
                var row = grid.getSelectedRow();
                if(row != null)
                {
                    var path = "/Manage/TraiffDetail?tariffID=@Model.CurrentTraiff&areaCode="+row.区号;
                    window.location.href=path;
                }
            }
        });

        $("#btnDelete").ligerButton(
        {
            click: function () {
                var row = grid.getSelectedRow();
                if(row != null)
                {
                    del('@Model.CurrentTraiff',row.区号);
                }
            }
        });
    });
</script>
</div>